@extends('template.adminpage')
@section('content')

<ol class="breadcrumb">
  <li class="active">Kertas</li>
</ol>

<div class="container-black">
  <label style="margin-top:10px"><u>Pencarian</u></label>
  
	<form action="{{URL::to('/master/paper')}}" method="POST">
         <div class="row">
          <div class="col-md-8">
            <div class="col-md-1">
              <input name="filter" value="type" type="radio" <?php if(Session::get('filter')=="type") echo "checked" ?> required ></input>
            </div>
            <div class="col-lg-2">
            <label>Kertas untuk</label>
            </div>
            <div class="col-lg-4">
               <select  class="form-control" name="typeby"  style="height:30px">
            <?php
            $type = array('all'=>'All','bill' => 'Bill','brochure' => 'Brosur', 'envelope' => 'Envelope', 'flayer' => 'Flayer', 'letterhead' => 'Letterhead', 'packaging' => 'Packaging');
            foreach ($type as $key => $val) {
                if ($key == Session::get('list')) {
                    echo '<option value="' . $key . '" selected>' . $val . '</option>';
                } else {
                    echo '<option value="' . $key . '">' . $val . '</option>';
                }
            }
            ?>
              </select>
            </div>
          </div>
          </div>
          <br>

          <div class="row">
          <div class="col-md-8">
            <div class="col-md-1">
              <input name="filter" value="keyword" type="radio" <?php if(Session::get('filter')=="keyword") echo "checked" ?>></input>
            </div>
            <div class="col-lg-2">
            <label>Nama kertas</label>
            </div>
            <div class="col-lg-4">
              <input type="text"  class="form-control" placeholder="Nama kertas" name="name" style="height:30px" value="{{Session::get('name')}}" ></input>
            </div>
          </div>
          </div>
          <br>
          <div class="row">
          <div class="col-md-8">
            <div class="col-md-4 col-md-offset-3">
                 <button class="btn btn-sm btn-dark" type="submit" style="width:100px;height:30px"><span class="fa fa-search"></span> Tampilkan</button>
            </div>
          </div>
          </div>
        

    </form>
    <br>
    <form action="{{URL::to('/master/papers/deletepapers')}}"  method="post" >
    <p><a data-toggle="modal" data-target="#addpapers"><button class="btn btn-sm btn-dark" style="height:30px" ><span class="fa fa-plus"></span> Tambah</button></a> <button class="btn btn-sm btn-dark" type="submit" style="height:30px" ><span class="fa  fa-times"></span> Hapus</button></p>
  	 <?php
        $limit = 10;
        if(Input::get('page')==0 OR Input::get('page')==1){ 
         $no = 1;
        }
        else{
        $no = ((Input::get('page')-1)*$limit)+1;
        } ?>
     <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th><input type="checkbox" name="checkall" id="terserah" onclick="check_all('terserah', {{$no}})" ></input></th>
          <th>No</th>
          <th>Tipe (Kertas untuk)</th>
          <th>Nama kertas</th>
          <th>Aksi</th>
        </tr>
      </thead>
      <tbody>
        
        @foreach($papers as $paper)
        <tr>
          <td><input type="checkbox" name="{{$paper->papertype_id}}" value="1" id="terserah_{{$no}}" ></input></td>
          <td>{{$no}}</td>
          <td>{{$paper->papertype_type}}</td>
          <td>{{$paper->papertype_name}}</td>
          <td><a data-toggle="modal" data-target="#{{$paper->papertype_id}}"><button class="btn btn-xs btn-dark"><span class="fa fa-edit"></span> Ubah</button></a></td>
        </tr>
        <?php $no++; ?>
        @endforeach
      </tbody>
    </table>
     <div class="text-right"><?php echo $papers->links(); ?></div>
  </form>
   

     <div class="modal fade" id="addpapers" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 
                    <h4 align="center" class="modal-title"> <label style="margin-top:5px; margin-bottom:25px">Tambah data kertas</label></h4>
                    </div>
                   <div align="left">
                   <br>
                          {{Form::open(array(
                                'url' => '/master/papers/addpapers',
                                'method' => 'POST'
                              ))}}
                          <div class="row">
                          <div class="col-md-8 col-md-offset-1">

                                   <div class="row">
                                  <div class="col-lg-4">
                                  <label>Jenis fitur</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <select  class="form-control" name="papertype_type" style="width:200px;height:30px" >
                                      <option value="brochure">Brosur</option>
                                      <option value="bill">Bill</option>
                                      <option value="envelope">Envelope</option>
                                      <option value="packaging">Packaging</option>
                                      <option value="letterhead">Letterhead</option>
                                      <option value="flayer">Flayer</option>
                                    </select>
                                  </div>
                                  </div>
                                  <br>
                                  <div class="row">
                                  <div class="col-lg-4">
                                  <label>Nama kertas <font color="red"> *</font></label>
                                  </div>
                                  <div class="col-lg-4">
                                    <input type="text"  class="form-control"  name="papertype_name" placeholder="Nama kertas"style="width:200px;height:30px" value="" required /></input>
                                  </div>
                                  </div>
                                  
                                    <br>
                                      <font color="red" class="text-left">* Data tidak boleh kosong</font>



                          </div>

                          </div>

                </div>


                    <div class="modal-footer">

                    <button type="submit" class="btn btn-sm btn-dark"><span class="fa fa-floppy-o"></span> Simpan</button>{{Form::close()}} <button class="btn btn-sm btn-dark" style="margin-right:5px" class="close" data-dismiss="modal"><span class="fa fa-times"></span> Batal</button></a>
                         
                    </div>
                  </div>
                </div>
              </div>

              @foreach($papers as $papers)
              <div class="modal fade" id="{{$papers->papertype_id}}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 
                    <h4 align="center" class="modal-title"> <label style="margin-top:5px; margin-bottom:25px">Ubah data kertas</label></h4>
                    </div>
                    <div align="left">
                              {{Form::open(array(
                                    'url' => '/master/papers/editpapers/'.$papers->papertype_id,
                                    'method' => 'POST'
                                  ))}}
                              <div class="row" style="margin-top:10px">
                              <div class="col-md-8 col-md-offset-1">

                                   <div class="row">
                                  <div class="col-lg-4">
                                  <label>Jenis fitur</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <select  class="form-control" name="papertype_type" style="width:250px;height:30px" >
                                      <option value="brochure">Brosur</option>
                                      <option value="bill">Bill</option>
                                      <option value="envelope">Envelope</option>
                                      <option value="packaging">Packaging</option>
                                      <option value="letterhead">Letterhead</option>
                                      <option value="flayer">Flayer</option>
                                    </select>
                                  </div>
                                  </div>
                                  <br>
                                  <div class="row">
                                  <div class="col-lg-4">
                                  <label>Nama kertas <font color="red"> *</font></label>
                                  </div>
                                  <div class="col-lg-4">
                                    <input type="text"  class="form-control"  name="papertype_name" placeholder="Nama fitur"style="width:250px;height:30px" value="{{$papers->papertype_name}}" required /></input>
                                  </div>
                                  </div>
                                  <br>

                              </div>
                              </div>   
                    
                    </div>
                    <div class="modal-footer">

                    <button type="submit" class="btn btn-sm btn-dark"><span class="fa fa-floppy-o"></span> Simpan</button>{{Form::close()}} <button class="btn btn-sm btn-dark" style="margin-right:5px" class="close" data-dismiss="modal"><span class="fa fa-times"></span> Batal</button></a>
                         
                    </div>
                  </div>
                </div>
              </div>
              @endforeach

</div>
@stop
@stop